package com.zlz.mapreduce.partition;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;

/**
 * @author: zlz
 * @date: 2022/1/2 20:08
 * @description:
 * @since: JDK1.8
 */
public class ProvincePartition extends Partitioner<Text, FlowBean> {
    @Override
    public int getPartition(Text text, FlowBean flowBean, int numPartitions) {
        String phone = text.toString();
        String prePhone = phone.substring(0, 2);

        int partition = 0;
        if ("13".equals(prePhone)) {
        } else if ("15".equals(prePhone)) {
            partition = 1;
        } else if ("17".equals(prePhone)) {
            partition = 2;
        } else if ("18".equals(prePhone)) {
            partition = 3;
        } else {
            partition = 4;
        }

        return partition;
    }
}
